#!/usr/bin/env python
# --*-- coding:utf-8 --*--
# author:g-y-b time:2020/5/25
from PyQt5.QtCore import QTimer, QCoreApplication
from PyQt5.QtGui import QImage, QPixmap
from PyQt5.QtWidgets import QMainWindow, QApplication, QFileDialog
from duidie import Ui_MainWindow
from PyQt5.Qt import *
import sys
from one_ui import one_ui
from two_ui import two_ui
from three_ui import three_ui
from four_ui import four_ui


class duidie_ui(QMainWindow, Ui_MainWindow):
    # 在实例化first类时，会自动调用它的初始化函数，因此，我们把想要让程序自动实现的程序功能都放在该函数下
    def __init__(self, parent=None):
        super(duidie_ui, self).__init__(parent)
        self.setupUi(self)
        self.CallBackFunctions()  # 各个控件背后的功能函数的集合，它定义了我们在程序界面上进行某项操作后实际执行的代码
        # 设置堆叠布局给self.frame_2
        self.qsl = QStackedLayout(self.frame_2)

        one = one_ui()
        two = two_ui()
        three = three_ui()
        four = four_ui()

        self.qsl.addWidget(one)
        self.qsl.addWidget(two)
        self.qsl.addWidget(three)
        self.qsl.addWidget(four)

    def CallBackFunctions(self):
        self.pushButton_0.clicked.connect(self.show_panel)
        self.pushButton_1.clicked.connect(self.show_panel)
        self.pushButton_2.clicked.connect(self.show_panel)
        self.pushButton_3.clicked.connect(self.show_panel)

    def show_panel(self):
        dic = {
            "pushButton_0": 0,
            "pushButton_1": 1,
            "pushButton_2": 2,
            "pushButton_3": 3,
        }
        index = dic[self.sender().objectName()]
        self.qsl.setCurrentIndex(index)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ui = duidie_ui()
    ui.show()
    sys.exit(app.exec_())
